#!/bin/sh /etc/rc.common

USE_PROCD=1
START=99

start_service() {
        local nofile=$(cat /proc/sys/fs/nr_open)
        local wanmode=$(uci get dockerd.@docker[0].wan_mode)
        
        if [ $wanmode = "1" ] ;then
            dockerwan="--iptables=true --ip-masq=true"
        else
            dockerwan="--iptables=false"
        fi

        procd_open_instance
        procd_set_param stderr 1
        procd_set_param command /usr/bin/dockerd $dockerwan
        procd_set_param limits nofile="${nofile} ${nofile}"
        procd_close_instance
        
}
